﻿using FluentValidation;
using RockBus.DataContracts;

namespace RockBus.ConfigurationService.Validation
{
    public class PublisherInfoValidator : AbstractValidator<PublisherInfo>
    {
        public PublisherInfoValidator()
        {
            this.RuleFor(x => x.Id).NotNull();
            this.RuleFor(x => x.Id).NotEmpty();
            //this.RuleFor(x => x.Namespaces).NotNull();
            //this.RuleFor(x => x.Namespaces).NotEmpty();
            //this.RuleFor(x => x.Namespaces).SetCollectionValidator(new NamespaceInfoValidator());
            this.RuleFor(x => x.InfoDictionary).NotNull();
            this.RuleFor(x => x.InfoDictionary).NotEmpty();
            this.RuleFor(x => x.InfoDictionary.Values).SetCollectionValidator(new ReceivePortInfoValidator());
            //this.RuleFor(x => x.ReceivePorts).Must((pub, advs) => ReferToExistingEndpoints(sub, subs)).WithMessage("A Subscription EndpointId does not exist in the Subscriber's list of endpoints.");
        }
    }
}